include("dbconnect.php"); $locsection_id = 1; $loccategory_id = 0; $locphoto_id = 0; $loctitle = ''; $locdate_text = ''; $loclocation = ''; $locprice = ''; $locabstract = ''; $locfilename = ''; $locorder_num = 50; if (isset($_GET["category_id"])) { // set category_id from url $loccategory_id = $_GET['category_id']; // are we editing an existing category? if (isset($_GET["photo_id"])) { $locphoto_id = $_GET['photo_id']; } $qry_section_text = "SELECT section_id FROM tbl_categories WHERE category_id = " .$loccategory_id; $qry_section = mysql_query($qry_section_text); While ($row = mysql_fetch_array($qry_section)) { $locsection_id = $row['section_id']; } //file delete if (isset($_GET["delete"])) { //get the filename $qry_filename_text = "SELECT filename FROM tbl_photos WHERE photo_id = " .$locphoto_id; $qry_filename = mysql_query($qry_filename_text); if (!$qry_filename) { die('Invalid query: ' . mysql_error()); } While ($row = mysql_fetch_array($qry_filename)) { $filename = $row['filename']; } //delete the file $file = 'photos/'.$filename; unlink($file); //clear the filename from the database $delete_file_text = "DELETE FROM tbl_photos WHERE photo_id = ". $locphoto_id; $delete_file = mysql_query($delete_file_text); if (!$delete_file) { die('Invalid query: ' . mysql_error()); } //redirect to the upload page header( 'Location:popup.php?category_id=' . $loccategory_id .'&return=' .$_GET["return"] ) ; } //end file delete } //get photo details $qry_photo_text = "SELECT title, date_text, location, price, abstract, filename, order_num FROM tbl_photos WHERE photo_id = " .$locphoto_id; $qry_photo = mysql_query($qry_photo_text); if (!$qry_photo) { die('Invalid query: ' . mysql_error()); } While ($row = mysql_fetch_array($qry_photo)) { $loctitle = $row['title']; $locdate_text = $row['date_text']; $loclocation = $row['location']; $locprice = $row['price']; $locabstract = $row['abstract']; $locfilename = $row['filename']; $locorder_num = $row['order_num']; } //check to see if you're logged in if (isset($_COOKIE["user"])) //set the cookie to continue for another hour setcookie("user", "Eileen", time()+3600); else //redirect to the login page //header( 'Location: login.php?return=edit_photo.php?photo_id=' .$locphoto_id .'&category_id=' .$loccategory_id ) ; ?>
Delete Photo | |
Delete Image? | [delete this photo] |